<template>
  <div class="app-container">
    <!-- 查询对话框   -->
    <el-dialog
      :title="title"
      v-model="openSearch"
      :close-on-click-modal="false"
      draggable
      width="780px"
      append-to-body
    >
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        label-width="98px"
      >
        <el-col :span="12">
          <el-form-item label="出库日期">
            <el-date-picker
              v-model="daterangeChmCkrq"
              size="small"
              value-format="yyyy-MM-dd HH:mm:ss"
              :default-time="['00:00:00', '23:59:59']"
              type="daterange"
              range-separator="-"
              style="width: 220px"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="制造车间" prop="cldCj">
            <el-select
              v-model="queryParams.cldCj"
              placeholder="请选择制造车间"
              clearable
            >
              <el-option
                v-for="dict in itCarOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="领料单号" prop="clmDjbh">
            <el-input
              v-model="queryParams.clmDjbh"
              placeholder="请输入领料单号"
              clearable
              size="small"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="制造单号" prop="cldZzdh">
            <el-input
              v-model="queryParams.cldZzdh"
              placeholder="请输入制造单号"
              clearable
              size="small"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="物料代码" prop="cldWldm">
            <el-input
              v-model="queryParams.cldWldm"
              placeholder="请输入物料代码"
              clearable
              size="small"
            />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="出库仓库" prop="ckDm">
            <el-select
              v-model="queryParams.ckDm"
              multiple
              placeholder="请选择出库仓库"
            >
              <el-option
                v-for="item in allStorageOptions"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label-width="125px" prop="itmPmgg">
            <span slot="label">
              <el-tooltip
                content="综合查询包含品名规格，客户编码查询"
                placement="top"
              >
                <i class="el-icon-question"></i>
              </el-tooltip>
              综合查询
            </span>
            <el-input
              type="textarea"
              v-model="queryParams.itmPmgg"
              clearable
              size="small"
              style="width: 480px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            style="margin-top: 25px; display: flex; justify-content: flex-end"
          >
            <el-button @click="cancel">取消</el-button>
            <el-button type="primary" @click="handleQuery">确认</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-dialog>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-search"
          @click="handleSearch"
          size="small"
          >查询</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['output:chmAnalyse:export']"
          @click="handleDc(1, '生产领料明细')"
          size="small"
        >
          明细数据导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['output:chmAnalyse:export']"
          @click="handleDc(2, '物料统计')"
          size="small"
        >
          物料统计导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['output:chmAnalyse:export']"
          @click="handleDc(3, '物料统计')"
          size="small"
        >
          仓库统计导出
        </el-button>
      </el-col>
    </el-row>
    <el-tabs v-model="activeTab">
      <el-tab-pane label="明细数据" name="first">
        <el-table
          border
          stripe
          :height="tableHChild"
          @scrollBottom="load"
          :data="chdDetailList"
          id="exportPzMxTj"
          :cell-style="styleCell"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column
            label="领料单号"
            align="center"
            width="135"
            prop="clmDjbh"
          />
          <el-table-column
            label="制造单号"
            align="center"
            width="145"
            prop="cldZzdh"
          />
          <el-table-column
            label="父项品名规格"
            align="center"
            width="145"
            prop="itmFxPmgg"
          />
          <el-table-column
            label="领料类型"
            :show-overflow-tooltip="true"
            width="100"
            align="center"
            prop="clmType"
          >
            <template #default="scope">
              <dict-tag :options="clmTypeOptions" :value="scope.row.clmType" />
            </template>
          </el-table-column>
          <el-table-column
            label="制造车间"
            width="135"
            align="center"
            prop="cldCj"
          >
            <template #default="scope">
              <dict-tag :options="itCarOptions" :value="scope.row.cldCj" />
            </template>
          </el-table-column>
          <el-table-column
            label="仓库"
            class-name="rkck"
            width="100"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmCkdm"
          >
            <template #default="scope">
              <dict-tag
                :options="allStorageOptions"
                :value="scope.row.clmCkdm"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="销售单号"
            width="135"
            align="center"
            prop="cldSodh"
          />
          <el-table-column
            label="物料代码"
            width="135"
            align="center"
            prop="cldWldm"
          />
          <el-table-column
            label="品名规格"
            width="285"
            show-overflow-tooltip
            prop="itmPmgg"
          />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            width="80"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column
            label="最小包装"
            width="80"
            align="center"
            prop="cldMinbz"
          />
          <el-table-column
            label="申请数量"
            width="80"
            align="center"
            prop="cldSqsl"
          />
          <el-table-column
            label="出库数量"
            width="80"
            align="center"
            prop="cldCksl"
          />
          <el-table-column
            label="存放位置"
            width="100"
            align="center"
            prop="cldCwdm"
          >
            <template #default="scope">
              <dict-tag :options="allCwOptions" :value="scope.row.cldCwdm" />
            </template>
          </el-table-column>
          <el-table-column
            label="原因类型"
            width="80"
            align="center"
            prop="clmYydm"
          >
            <template v-slot="scope">
              <dict-tag
                :options="reasonCategoryOptions"
                :value="scope.row.clmYydm"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="原因描述"
            width="80"
            align="center"
            prop="clmYyms"
          >
            <template v-slot="scope">
              <dict-tag
                :options="reasonDescribeOptions"
                :value="scope.row.clmYyms"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="备注"
            width="80"
            align="center"
            prop="clmDesc"
          />
          <el-table-column
            label="部门名称"
            width="100"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmBmdm"
          ></el-table-column>
          <el-table-column
            label="开单人员"
            width="100"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmJlry"
          />
          <el-table-column
            label="开单日期"
            :show-overflow-tooltip="true"
            align="center"
            width="150"
            prop="clmJlrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.clmJlrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="审核人员"
            width="80"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmShry"
          />
          <el-table-column
            label="审核日期"
            width="150"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmShrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.clmShrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="出库人员"
            width="80"
            :show-overflow-tooltip="true"
            align="center"
            prop="cldCkry"
          />
          <el-table-column
            label="出库日期"
            width="150"
            :show-overflow-tooltip="true"
            align="center"
            prop="cldCkrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.cldCkrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="过账人员"
            width="80"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmGzry"
          />
          <el-table-column
            label="过账日期"
            width="150"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmGzrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.clmGzrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="按物料统计" name="second">
        <el-table
          border
          stripe
          @scrollBottom="load2"
          :height="tableHChild"
          :data="chdWldmList"
          :cell-style="styleCell"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column label="物料代码" align="center" prop="cldWldm" />
          <el-table-column label="品名规格" align="center" prop="itmPmgg" />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="申请数量" align="center" prop="cldSqsl" />
          <el-table-column label="出库数量" align="center" prop="cldCksl" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="按仓库统计" name="third">
        <el-table
          border
          stripe
          :height="tableHChild"
          @scrollBottom="load3"
          :data="chdStorageList"
          :cell-style="styleCell"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column label="仓库" align="center" prop="clmCkdm">
            <template #default="scope">
              <dict-tag
                :options="allStorageOptions"
                :value="scope.row.clmCkdm"
              />
            </template>
          </el-table-column>
          <el-table-column label="物料代码" align="center" prop="cldWldm" />
          <el-table-column label="品名规格" align="center" prop="itmPmgg" />
          <el-table-column label="单位" align="center" prop="itmDw">
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="申请数量" align="center" prop="cldSqsl" />
          <el-table-column label="出库数量" align="center" prop="cldCksl" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="按日期统计" name="fourth">
        <el-table
          border
          stripe
          :height="tableHChild"
          @scrollBottom="load6"
          :data="cldDateList"
          :cell-style="styleCell"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column
            label="过账日期"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmGzrq"
          />
          <el-table-column label="物料代码" align="center" prop="itmWldm" />
          <el-table-column label="品名规格" align="center" prop="itmPmgg" />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="出库数量" align="center" prop="cldCksl" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="未过账数据" name="first2">
        <el-table
          border
          stripe
          :height="tableHChild"
          @scrollBottom="load4"
          :data="chdList4"
          :cell-style="styleCell"
          id="chdList4"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column
            label="领料单号"
            align="center"
            width="135"
            prop="clmDjbh"
          />
          <el-table-column
            label="制造单号"
            align="center"
            width="135"
            prop="cldZzdh"
          />
          <el-table-column
            label="领料类型"
            :show-overflow-tooltip="true"
            width="100"
            align="center"
            prop="clmType"
          >
            <template #default="scope">
              <dict-tag :options="clmTypeOptions" :value="scope.row.clmType" />
            </template>
          </el-table-column>
          <el-table-column
            label="制造车间"
            width="135"
            align="center"
            prop="cldCj"
          >
            <template #default="scope">
              <dict-tag :options="itCarOptions" :value="scope.row.cldCj" />
            </template>
          </el-table-column>
          <el-table-column
            label="仓库"
            class-name="rkck"
            width="100"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmCkdm"
          >
            <template #default="scope">
              <dict-tag
                :options="allStorageOptions"
                :value="scope.row.clmCkdm"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="销售单号"
            width="135"
            align="center"
            prop="cldSodh"
          />
          <el-table-column
            label="物料代码"
            width="135"
            align="center"
            prop="cldWldm"
          />
          <el-table-column
            label="品名规格"
            width="285"
            show-overflow-tooltip
            prop="itmPmgg"
          />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            width="80"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column
            label="最小包装"
            width="80"
            align="center"
            prop="cldMinbz"
          />
          <el-table-column
            label="申请数量"
            width="80"
            align="center"
            prop="cldSqsl"
          />
          <el-table-column
            label="出库数量"
            width="80"
            align="center"
            prop="cldCksl"
          />
          <el-table-column
            label="存放位置"
            width="100"
            align="center"
            prop="cldCwdm"
          >
            <template #default="scope">
              <dict-tag :options="allCwOptions" :value="scope.row.cldCwdm" />
            </template>
          </el-table-column>
          <el-table-column
            label="原因类型"
            width="80"
            align="center"
            prop="clmYydm"
          >
            <template v-slot="scope">
              <dict-tag
                :options="reasonCategoryOptions"
                :value="scope.row.clmYydm"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="原因描述"
            width="80"
            align="center"
            prop="clmYyms"
          >
            <template v-slot="scope">
              <dict-tag
                :options="reasonDescribeOptions"
                :value="scope.row.clmYyms"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="备注"
            width="80"
            align="center"
            prop="clmDesc"
          />
          <el-table-column
            label="部门名称"
            width="100"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmBmdm"
          ></el-table-column>
          <el-table-column
            label="开单人员"
            width="100"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmJlry"
          />
          <el-table-column
            label="开单日期"
            :show-overflow-tooltip="true"
            align="center"
            width="150"
            prop="clmJlrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.clmJlrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="审核人员"
            width="80"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmShry"
          />
          <el-table-column
            label="审核日期"
            width="150"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmShrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.clmShrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="出库人员"
            width="80"
            :show-overflow-tooltip="true"
            align="center"
            prop="cldCkry"
          />
          <el-table-column
            label="出库日期"
            width="150"
            :show-overflow-tooltip="true"
            align="center"
            prop="cldCkrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.cldCkrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="过账人员"
            width="80"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmGzry"
          />
          <el-table-column
            label="过账日期"
            width="150"
            :show-overflow-tooltip="true"
            align="center"
            prop="clmGzrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.clmGzrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="公司出库单" name="fifth">
        <el-table border stripe :height="tableHChild" :data="chdCusList">
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column label="出货单号" align="center" prop="chdDjbh" />
          <el-table-column
            label="客户"
            :show-overflow-tooltip="true"
            align="center"
            prop="chmKhdm"
          >
            <template #default="scope">
              <dict-tag
                :options="allCustomerOptions"
                :value="scope.row.chmKhdm"
              />
            </template>
          </el-table-column>
          <el-table-column label="物料名称" align="center" prop="itmWlpm" />
          <el-table-column label="物料规格" align="center" prop="itmWlgg" />
          <el-table-column label="客户编号" align="center" prop="itmCustwldm" />
          <el-table-column label="物料代码" align="center" prop="chdWldm" />
          <el-table-column label="出库数量" align="center" prop="chdCksl" />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="出库日期" align="center" prop="chdCkrq" />
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { getAll, getstorageType } from "@/api/repertory/Storage";
import { exportChmReport } from "@/api/output/proShipped";
import { getAllCustomerTwo } from "@/api/project/customer";
import { clmList, exportClmList } from "@/api/output/clmReport";

export default {
  name: "ClmReport",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      tableH: (document.body.clientHeight - 130) / 2,
      tableHChild: document.body.clientHeight - 280,
      activeTab: "first",
      chdDetailList: [],
      chdList4: [],
      chdStorageList: [],
      chdCusList: [],
      cldDateList: [],
      chdWldmList: [],
      // 显示搜索条件
      openSearch: false,
      // 总条数
      total: 0,
      total2: 0,
      total3: 0,
      total4: 0,
      total5: 0,
      total6: 0,
      // 有效存储仓库
      storageOptions: [],
      // 所以存储仓库
      allStorageOptions: [],
      // 所有客户代码字典
      allCustomerOptions: [],
      // 所有出库类型字典
      clmTypeOptions: [],
      // 所有存储储位
      allCwOptions: [],
      // 单位字典
      unitFlagOptions: [],
      // 原因类别
      reasonCategoryOptions: [],
      // 原因描述
      reasonDescribeOptions: [],
      itCarOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 建立日期时间范围
      daterangeChmCkrq: [
        this.$moment().startOf("month").toDate(),
        this.$moment().endOf("month").toDate(),
      ],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 40,
        clmWldm: null,
        clmDjbh: null,
        ckDm: null,
        cldZzdh: null,
        itmPmgg: null,
        index: 1,
      },
      //日期初始化
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    };
  },
  created() {
    this.getList();
    //单位
    this.getDicts("sys_unit").then((response) => {
      this.unitFlagOptions = response.data;
    });
    getstorageType("0").then((response) => {
      this.storageOptions = response.data;

      for (let item of this.storageOptions) {
        item.dictLabel = item.storageName;
        item.listClass = "default";
        item.dictValue = item.storageId + "";
      }
    });

    getAll().then((response) => {
      this.allCwOptions = response.data;

      for (let item2 of this.allCwOptions) {
        item2.dictLabel = item2.storageDefaultstorage;

        item2.listClass = "default";
        item2.dictValue = item2.storageId + "";
      }
    });

    getAll().then((response) => {
      this.allStorageOptions = response.data;

      for (let item of this.allStorageOptions) {
        item.dictLabel = item.storageName;
        item.listClass = "default";
        item.dictValue = item.storageId + "";
      }
      // this.allStorageOptions.push(data)
    });
    getAllCustomerTwo().then((response) => {
      for (let i of response.data) {
        i.dictLabel = i.cusName;
        i.dictValue = i.cusId + "";
        i.listClass = "default";
      }
      this.allCustomerOptions = response.data;
    });
    //所有出货类型
    this.getDicts("production_pick_type").then((response) => {
      this.clmTypeOptions = response.data;
    });
    // 原因类别
    this.getDicts("reason_category").then((response) => {
      this.reasonCategoryOptions = response.data;
    });
    // 原因描述
    this.getDicts("reason_describe").then((response) => {
      this.reasonDescribeOptions = response.data;
    });
    //制造车间字典
    this.getDicts("Manufacturing_plant").then((response) => {
      this.itCarOptions = response.data;
    });
  },
  methods: {
    /** 查询来料进货入库开单列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeChmCkrq && "" != this.daterangeChmCkrq) {
        this.queryParams.params["begincldCkrq"] = this.moment(
          this.daterangeChmCkrq[0]
        ).format("YYYY-MM-DD HH:mm:ss");
        this.queryParams.params["endcldCkrq"] = this.moment(
          this.daterangeChmCkrq[1]
        ).format("YYYY-MM-DD HH:mm:ss");
      }
      clmList(this.queryParams).then((response) => {
        this.chdDetailList = [];
        this.chdWldmList = [];
        this.chdStorageList = [];
        this.cldDateList = [];
        this.chdCusList = [];
        this.chdList4 = [];
        //明细
        this.chdDetailList = response.data.list1.rows;
        this.total = response.data.list1.total;
        //物料
        this.chdWldmList = this.chdWldmList.concat(response.data.list2.rows);
        this.total2 = response.data.list2.total;
        //仓库
        this.chdStorageList = this.chdStorageList.concat(
          response.data.list3.rows
        );
        this.total3 = response.data.list3.total;

        this.chdList4 = this.chdList4.concat(response.data.list4.rows);
        this.total4 = response.data.list4.total;

        this.cldDateList = this.cldDateList.concat(response.data.list6.rows);
        this.total6 = response.data.list6.total;

        this.loading = false;
      });
    },
    load() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        clmList(this.queryParams).then((response) => {
          //明细
          this.chdDetailList = this.chdDetailList.concat(
            response.data.list1.rows
          );
          this.total = response.data.list1.total;
          this.loading = false;
        });
      }
      return 0;
    },
    load2() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total2 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        clmList(this.queryParams).then((response) => {
          //明细
          this.chdWldmList = this.chdWldmList.concat(response.data.list2.rows);
          this.total2 = response.data.list2.total;
          this.loading = false;
        });
      }
      return 0;
    },
    load3() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total3 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        clmList(this.queryParams).then((response) => {
          //明细
          this.chdStorageList = this.chdStorageList.concat(
            response.data.list3.rows
          );
          this.total2 = response.data.list3.total;
          this.loading = false;
        });
      }
      return 0;
    },
    load4() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total4 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        clmList(this.queryParams).then((response) => {
          //明细
          this.chdList4 = this.chdList4.concat(response.data.list4.rows);
          this.total4 = response.data.list4.total;
          this.loading = false;
        });
      }
      return 0;
    },
    load6() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total6 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        clmList(this.queryParams).then((response) => {
          //明细
          this.cldDateList = this.cldDateList.concat(response.data.list6.rows);
          this.total6 = response.data.list6.total;
          this.loading = false;
        });
      }
      return 0;
    },
    // listed(){
    //   listData(this.queryParams).then(response => {
    //     //明细
    //     this.chdDetailList = this.chdDetailList.concat(response.data.list1.rows)
    //     this.total = response.data.list1.total
    //     //物料
    //     // this.chdWldmList = this.chdWldmList.concat(response.data.wldm.rows)
    //     // this.total2 = response.data.wldm.total
    //     // //日期
    //     // this.chdStorageList = this.chdStorageList.concat(response.data.date.rows)
    //     // this.total3 = response.data.date.total
    //     // //仓库
    //     // this.chdCusList = this.chdCusList.concat(response.data.cus.rows)
    //     // this.total4 = response.data.stroage.total
    //     this.loading = false
    //   })
    // },
    handleDc(index) {
      // exportTable(a, b)
      const queryParams = this.queryParams;
      queryParams.index = index;
      this.$confirm("是否确认导出所有生产领料统计分析?", "警告", {
        cancelButtonText: "取消",
        confirmButtonText: "确定",
        type: "warning",
      })
        .then(() => {
          this.exportLoading = true;
          return exportClmList(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
          this.exportLoading = false;
        })
        .catch(() => {});
    },
    handleSearch() {
      this.openSearch = true;
      this.title = "查询生产领料";
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.openSearch = false;
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      this.openSearch = false;
    },
    //导出Excel
    handleExcel(index) {
      this.queryParams.index = index;
      const queryParams = this.queryParams;
      exportChmReport(queryParams).then((response) => {
        this.download(response.msg);
        this.queryParams.index = 0;
      });
    },
    styleCell({ row, column, rowIndex, columnIndex }) {
      if (row[column.property] && row[column.property] < 0)
        return { color: "red" };
    },
  },
};
</script>
